﻿package com.wongoing.sys.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wongoing.base.BaseServiceImpl;
import com.wongoing.base.PageResult;
import com.wongoing.sys.dao.SysBasArticleDao;
import com.wongoing.sys.model.SysBasArticle;
import com.wongoing.sys.model.ext.SysBasArticleExt;
import com.wongoing.sys.service.SysBasArticleService;

@Service("sysBasArticleService")
public class SysBasArticleServiceImpl extends BaseServiceImpl<SysBasArticle> implements SysBasArticleService {
	private SysBasArticleDao dao;

	@Autowired
	public void setDao(SysBasArticleDao dao) {
		super.setDao(dao);
		this.dao = dao;
	}
	/**
	 * 功能说明：通过PageResult获取分享分页数据
	 * 修改说明：
	 * @author zhaoxihao
	 * @date 2017年10月17日 下午15:32:41
	 * @param pageResult 分页对象包含查询条件
	 * @return 返回分页对象包含页面数据
	 */
	public PageResult< SysBasArticleExt> getArticleListPageResult(PageResult< SysBasArticleExt> pageResult) {
		pageResult.getParam().put("offset", pageResult.getPageSize() * (pageResult.getPageCurrent() - 1));
		if (!"".equals(pageResult.getOrderField())) { pageResult.getParam().put("orderColumn", pageResult.getOrderField()); }
		pageResult.getParam().put("orderTurn", pageResult.getOrderDirection());
		List<SysBasArticleExt> data = dao.getArticleListByParam(pageResult.getParam());
		pageResult.setList(data);
		int totalSize = dao.countOfArticleListByParam(pageResult.getParam());
		pageResult.setTotal(totalSize);
		return pageResult;
	}
	public List< SysBasArticleExt> getArticleListByParam(Map<String, Object> params) {
		return this.dao.getArticleListByParam(params);
	}
	public List< SysBasArticleExt> getArticleById(Map<String, Object> params) {
		return this.dao.getArticleById(params);
	}
}
